<template>
	<view :class="currentTheme">
		<a-nabbar :name="'账户信息'" />
		<view v-if="pageLoading">
			<view class="u-margin-top-45 u-padding-left-32 u-padding-right-32">
				<view class="account u-margin-bottom-26" @click="changePay(data)" v-for="(data,index) in list" :key="index">
					<item-box :padding="0">
						<view class="u-flex paycheck u-col-top u-padding-top-35 u-padding-left-25  u-padding-right-25  u-padding-bottom-35">
							<view v-if="data.list.length !== 0" class="u-margin-right-20">
								<u-icon name="alipay" v-if="data.type==1" custom-prefix="custom-icon" color="#1296db"
									size="40"></u-icon>
								<u-icon name="weixin11" v-if="data.type==2" custom-prefix="custom-icon" color="#61DC77"
									size="40"></u-icon>
								<u-icon name="yinhangqia" v-if="data.type==3" custom-prefix="custom-icon" color="#765CFE"
									size="30"></u-icon>
							</view>
							<view class="paychange u-flex u-flex-1 u-row-between">
								<view class="name" v-if="data.list.length !== 0">
									<view class="u-font-32">{{data.list[0].realName}}</view>
									<view class="u-font-30 accout">{{data.list[0].loginId}}</view>
								</view>
								<view v-else class="u-flex u-padding-top-30 u-padding-bottom-30">
									<view class="u-margin-right-24">
										<u-icon name="alipay" v-if="data.type==1" custom-prefix="custom-icon"
											color="#1296db" size="40"></u-icon>
										<u-icon name="weixin11" v-if="data.type==2" custom-prefix="custom-icon"
											color="#61DC77" size="40"></u-icon>
										<u-icon name="yinhangqia" v-if="data.type==3" custom-prefix="custom-icon"
											color="#765CFEs" size="30"></u-icon>
									</view>
									<view class="u-font-34 box-title text-bold">添加{{data.name}}账号</view>
								</view>
								<u-icon name="gengduopsd" custom-prefix="custom-icon" color="#B0B3D9" size="30"></u-icon>
							</view>
						</view>
					</item-box>
				</view>
			</view>
			<all-pay :visible.sync="show" :userPayType="1" :payType="type" @close="close" :payList="payList" @removeItem="removeItem"/>
		</view>
	</view>
</template>

<script>
	import allPay from "./wallet/allPay";
	import payMixins from "@/mixins/payMixins";
	import {deleteIds} from '@/api/crud.js'
	import {
		customRequest
	} from "@/api/crud";
	export default {
		name: "account",
		components: {
			allPay
		},
		mixins: [payMixins],
		data() {
			return {
				show: false,
				payList: [],
				type: '',
				name:'list',
				list: [{
						type: 1,
						name: '支付宝',
						list: []
					},
					{
						type: 2,
						name: '微信',
						list: []
					},
					// {
					// 	type: 3,
					// 	name: '银行卡',
					// 	list: []
					// },
				],
				pageLoading:false
			}
		},
		onShow() {
			this.payUserList()
			this.show = false
		},
		methods: {
			payUserList() {
				this.list.forEach(res => {
					this.type = res.type
					customRequest({
						uid: this.loginForm.uid,
						type: this.payType
					}, this.apiType, this.apiModule,this.name, 'get').then(data => {
						res.list = data
						if(!this.pageLoading) this.pageLoading = true
					})
				})
			},
			changePay(data) {
				console.log(data)
				if (data.list.length !== 0) {
					this.type = data.type
					this.show = true
					this.payList = data.list
				} else {
					if (data.type != 3) {
						this.$u.route({
							url: '/pagesB/wallet/addPay',
							params: {
								name: data.name,
								type: data.type
							}
						})
					} else {
						this.$u.route({
							url: '/pagesB/wallet/addCard',
						})
					}
					this.close()
				}
			},
			close() {
				this.show = false
			},
			removeItem(id){
				deleteIds('',this.apiType,this.apiModule,id).then(res=>{
					this.payUserList()
					this.show = false;
					this.$u.toast('删除成功')
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.paycheck {
		.name {
			color: var(--reversal-color);
			.accout {
				margin-top: 30rpx;
			}

		}
	}
</style>
